<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/pages/public/head.jsp"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'pagination.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	</head>

	<body>
		<div>
			<s:if test="page.totalPage>0">
				<a href="page.pageNo=1" id="startPage">首页</a>
			</s:if>
			<s:if test="page.pageNo>1">
				<a href="page.pageNo=${page.pageNo-1}" id="upPage">上一页</a>
			</s:if>
			<s:if test="page.pageNo<page.totalPage">
				<a href="page.pageNo=${page.pageNo+1}" id="nextPage">下一页</a>
			</s:if>
			<s:if test="page.totalPage>0">
				<a href="page.pageNo=${page.totalPage}" id="endPage">最后一页</a>
			</s:if>
		</div>
	</body>
	
	<script type="text/javascript">
		var url=window.location.href;
		var index =url.indexOf("?");
		var startUrl =url.substring(0,(index+1));
		
		var paramIndex =url.lastIndexOf("&");
		if(paramIndex<=0){
		 	paramIndex =url.length;
		 }
		
		var endUrl =url.substring((url.indexOf("?")+1), paramIndex);
		var newUrl;
		if(index<0){
			newUrl =endUrl+"?&";
		}else{
			newUrl =startUrl+endUrl+"&";
		}
		//首页
		var startPage =document.getElementById("startPage");
		if(startPage != null){
			var start =startPage.getAttribute("href",2);
			var stUrl =newUrl + start.substring(start.lastIndexOf("/"),start.length);
			startPage.setAttribute("href", stUrl);
		}
		//上一页
		var upPage =document.getElementById("upPage");
		if(upPage != null){
			var up =upPage.getAttribute("href",2);
			var upUrl =newUrl + up.substring(up.lastIndexOf("/"),up.length);
			upPage.setAttribute("href", upUrl);
		}
		
		//下一页
		var nextPage =document.getElementById("nextPage");
		if(nextPage != null){
			var next =nextPage.getAttribute("href",2);
			var nextUrl =newUrl + next.substring(next.lastIndexOf("/"),next.length);
			nextPage.setAttribute("href", nextUrl);
		}
		
		//最后一页
		var endPage =document.getElementById("endPage");
		if(endPage != null){
			var end =endPage.getAttribute("href",2);
			var endUrl =newUrl + end.substring(end.lastIndexOf("/"),end.length);
			endPage.setAttribute("href", endUrl);
		}
		
	</script>
</html>
